package IO;

import java.io.*;

/**
 * @ClassName : TransStreamDemo
 * @Author : LV88VL
 * @Date: 2021/3/18 16:43
 * @Description : 字符转换
 */
public class TransStreamDemo {
    public static void main(String[] args) throws IOException {
        writecn();
        readcn();
    }

    private static void readcn() throws IOException{
        InputStreamReader isr =new InputStreamReader(new FileInputStream("D:\\d.txt"),"utf-8");
        char[] buf=new char[1024];
        int len=isr.read(buf);
        System.out.println(new String(buf,0,len));
        isr.close();
    }

    private static void writecn() throws IOException {
        OutputStreamWriter isw = new OutputStreamWriter(new FileOutputStream("D:\\d.txt"),"utf-8");
        isw.write("你好，阿三");
        isw.close();
    }
}
